#include <stdio.h>
#include <stdlib.h>
#include <string.h>

enum GENDER
{
    male,
    female
};
enum MONTH
{
    JAN,
    FEB,
    MAR,
    APR,
    MAY,
    JUN,
    JUL,
    AUG,
    SEP,
    OCT,
    NOV,
    DEC
};

typedef struct
{
    int year;
    enum MONTH month;
    int day;
} Date;

typedef struct
{
    char no[11];
    char name[11];
    enum GENDER gender;
    char hometown[11];
    Date birthdate;
    float thScore;
    float exScore;
    float finalScore;
    int ranking;
} STUDENT;

int compareFinalScore(const void *a, const void *b)
{
    STUDENT *studentA = (STUDENT *)a;
    STUDENT *studentB = (STUDENT *)b;
    if (studentA->finalScore > studentB->finalScore)
        return -1;
    if (studentA->finalScore < studentB->finalScore)
        return 1;
    return 0;
}

int main()
{
    int numStudents;
    scanf("%d", &numStudents);

    STUDENT students[numStudents];

    for (int i = 0; i < numStudents; i++)
    {
        scanf("%s %s %c %s %d-%d-%d %f %f ",
              students[i].no, students[i].name,
              &students[i].gender,  // 直接读取字符
              students[i].hometown, // 读取 hometown
              &students[i].birthdate.year,
              &students[i].birthdate.month, // 直接读取整数值
              &students[i].birthdate.day,
              &students[i].thScore,
              &students[i].exScore);

        students[i].finalScore = students[i].thScore * 0.4 + students[i].exScore * 0.6;
    }

    qsort(students, numStudents, sizeof(STUDENT), compareFinalScore);

    for (int i = 0; i < numStudents; i++)
    {
        students[i].ranking = i + 1;
    }

    for (int i = 0; i < numStudents; i++)
    {
        printf("%d: %-8s%-8s%-6c%-10s%02d-%02d-%04d   %-8.1f%-8.1f%-8.1f\n",
               students[i].ranking, students[i].no, students[i].name,
               students[i].gender == male ? 'm' : 'f',
               students[i].hometown,            // 输出 hometown
               students[i].birthdate.month + 1, // 注意：这里加1是为了转换为1-12的月份表示
               students[i].birthdate.day, students[i].birthdate.year,
               students[i].thScore, students[i].exScore, students[i].finalScore);
    }

    return 0;
}